package com.yangle.frame.admin.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration

public class WebMvcConfiguration extends WebMvcConfigurerAdapter {
    //获取上传文件的路径
    @Value("${file.upload.path}")
    private String fileUploadPath;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        //addResourceHandler是指你想在url请求的路径

        //addResourceLocations是图片存放的真实路径

        registry.addResourceHandler("/images/**").addResourceLocations("file:"+fileUploadPath);
        super.addResourceHandlers(registry);
    }
}